package com.donger.upms.biz.controller;

import com.donger.common.core.constant.CommonConstants;
import com.donger.common.security.service.UserDetail;
import com.donger.common.security.utils.SecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * BaseController
 *
 * @author xyx
 * @date 2019-01-08 20:52
 */
public class BaseController implements CommonConstants {

    protected Logger log = LoggerFactory.getLogger(this.getClass());

    protected UserDetail getCurrentUser() {
        return SecurityUtil.getCurrentUserLogin().orElse(null);
    }

    protected Long getCurrentUserId() {
        UserDetail currentUser = getCurrentUser();
        if (currentUser == null) {
            return null;
        }
        return currentUser.getUserId();
    }

}
